<template>
  <div class="cloud_Service">
    <div class="Service_guarantee" @click="showOpen" v-if="checkList().length > 0">
      <div class="Service_guarantee_left">服务保障</div>
      <div class="Service_guarantee_conten">
        <div class="contenBtn" v-for="(item,index) in checkList()" :key="index">{{ item.name }}</div>
      </div>
      <i class="iconfont icon-advertise-next"></i>
    </div>
    <van-popup v-model="show" get-container="body" position="bottom" round :style="{ maxHeight: '30rem' }" @close="show_close">
      <div class="serviceBox">
        <div class="serviceBox_top">
          <div class="serviceBox_top_l">商品服务保障</div>
          <div class="serviceBox_top_r" @click="show = false">
            <i class="iconfont icon-icon_close"></i>
          </div>
        </div>
        <div class="serviceBox_lis">
          <div class="lis" @click="ruleShowTap(item.id)" v-for="item in checkList()" :key="item.id">
            <i class="iconfont icon-baozhang"></i>
            <div class="lis_conten">
              <div class="lis_conten_top">{{ item.name }}</div>
              <div class="lis_des">{{ item.main_desc }}</div>
            </div>
            <i class="iconfont icon-advertise-next"></i>
          </div>
        </div>
      </div>
      <div class="btn_b">
        <div class="btn" @click="show = false">完成</div>
      </div>
    </van-popup>
    <van-popup v-model="ruleShow" get-container="body" position="bottom" round :style="{ maxHeight: '30rem' }" @close="ruleShow_close">
      <div class="serviceBox">
        <div class="serviceBox_top">
          <div class="serviceBox_top_l">{{ rule.name }}须知</div>
          <div class="serviceBox_top_r" @click="ruleShow = false">
            <i class="iconfont icon-icon_close"></i>
          </div>
        </div>
        <div class="serviceBox_rule" v-html="rule.detail_desc"></div>
      </div>
    </van-popup>
  </div>
</template>
<script>
export default {
  props: ["goods_info"],
  data() {
    return {
      show: false,
      ruleShow: false,
      rule: []
    };
  },
  computed: {},
  mounted() {},
  methods: {
    checkList() {
      if (!this.goods_info?.plugin?.cloud_shop) return [];
      return this.goods_info?.plugin.cloud_shop.service_note;
    },
    showOpen() {
      console.log(this.show, this.goods_info);
      this.show = true;
    },
    show_close() {
      this.show = false;
    },
    ruleShow_close() {
      this.ruleShow = false;
    },
    async ruleShowTap(id) {
      let { data, msg, result } = await $http.post("plugin.cloud-shop.frontend.service-note.detail", { id: id }, "");
      if (result) {
        this.rule = data;
        this.ruleShow = true;
      } else {
        this.$toast(msg);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.btn_b {
  height: 3.75rem;
  background: #ffffff;
  padding: 0.59rem 0;
  box-shadow: 0rem -0.03rem 0.31rem 0.03rem #f5f5f5;
  .btn {
    width: 21.94rem;
    height: 2.5rem;
    background: #f15353;
    border-radius: 1.28rem 1.28rem 1.28rem 1.28rem;
    text-align: center;
    line-height: 2.5rem;
    margin: 0 auto;
    color: #ffffff;
  }
}
.serviceBox {
  padding: 1.19rem 0.75rem 0 0.75rem;
  .serviceBox_lis {
    .lis {
      display: flex;
      align-items: flex-start;
      margin-bottom: 1.44rem;
      .icon-baozhang {
        color: #f15353;
      }
      .lis_conten {
        flex: 1;
        text-align: left;
        margin-left: 0.28rem;
        .lis_conten_top {
          font-weight: 500;
          font-size: 0.94rem;
          color: #00001c;
          line-height: 1rem;
          margin-bottom: 0.84rem;
        }
        .lis_des {
          font-size: 0.81rem;
          color: #999999;
        }
      }
      .icon-advertise-next {
        color: #808080;
      }
    }
  }
  .serviceBox_rule {
    margin-top: 1.44rem;
  }
  .serviceBox_top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.53rem;
    .serviceBox_top_l {
      font-weight: bold;
      font-size: 1rem;
      color: #00001c;
    }
    .serviceBox_top_r {
      width: 1.5rem;
      height: 1.5rem;
      background: #f0f0f1;
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      .icon-ico_close {
        color: #6e6e79;
        font-size: 0.9rem;
      }
    }
  }
}
.Service_guarantee {
  margin: 0.63rem 0.72rem;
  padding: 0.97rem 0.75rem;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.81rem;
  .Service_guarantee_left {
    color: #6e6e79;
    flex-shrink: 0;
  }
  .Service_guarantee_conten {
    text-align: left;
    overflow-x: scroll;
    display: flex;
    justify-content: flex-start;
    .contenBtn {
      flex-shrink: 0;
      margin-left: 1.28rem;
      padding: 0.15rem 0.3rem;
      border: 1px solid #f69036;
      border-radius: 0.2rem;
      box-sizing: border-box;
      color: #f69036;
    }
  }
  .icon-advertise-next {
    color: #aaaab3;
    flex-shrink: 0;
  }
}
</style>